package algorithm.lanqiao.t19725;

import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main {
    static class IO {
        // 读
        static InputStreamReader ins = new InputStreamReader(System.in);
        static StreamTokenizer in = new StreamTokenizer(ins);
        static BufferedReader br = new BufferedReader(ins);

        // 写
        public static PrintWriter out = new PrintWriter(System.out);


        public static int readInt() {
            try {
                in.nextToken();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }

        public static String readLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        public static double readDouble() {
            try {
                in.nextToken();
            } catch (Exception e) {
                e.printStackTrace();
            }
            return in.nval;
        }
    }

    public static void main(String[] args) {
        int n = IO.readInt();
        double p = IO.readDouble();
        double minTotal = Double.MAX_VALUE;
        int k = Integer.MAX_VALUE;
        for(int i = n; i >= 1; i --) {
            if(n % i != 0) continue;
            double p1 = Math.pow(1-p,i);
            double total = (1-p1)*(i+1)*(1.0*n/i) + p1 * 1.0 * n/i;
           if(total < minTotal) {
               if(k > i) {
                   k = i;
                   minTotal = total;
               }
           }
        }
        System.out.println(k);
    }
}
